//
//  ContactTableViewCell.m
//  通讯录作业
//
//  Created by dllo on 16/6/22.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ContactTableViewCell.h"
#import "Contact.h"
#define  kWith self.contentView.frame.size.width
#define kHeight self.contentView.frame.size.height

@interface ContactTableViewCell()
@property(nonatomic,retain)UIImageView *image;
@property(nonatomic,retain)UILabel *nameLabel;
@property (nonatomic,retain)UILabel *numberLabel;

@end


@implementation ContactTableViewCell
-(void)dealloc{
    [_image release];
    [_nameLabel release];
    [_nameLabel release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        self.image =[[UIImageView alloc]init];
        
        [self.contentView addSubview:self.image];
        
        self.nameLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.nameLabel];
        [self.nameLabel release];
        
        self.numberLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.numberLabel];
        [self.numberLabel release];
        
        
    }
    return self;
    
}
-(void)layoutSubviews{
    [super layoutSubviews];
    self.image.frame =CGRectMake(10, 10, kWith * 0.3, kHeight - 20);
    self.nameLabel .frame = CGRectMake(_image.frame.size.width+40, 20, kWith*0.5, kHeight*0.2);
    self.numberLabel.frame = CGRectMake(_nameLabel.frame.origin.x, kHeight * 0.2 + 40, kWith * 0.5, kHeight * 0.2);

    
    
}
-(void)setContact:(Contact *)contact{
    if (_contact != contact) {
        [_contact release];
        _contact = [contact retain];
    }
    self.imageView.image = [UIImage imageNamed:contact.poto];
    self.nameLabel.text = contact.name;
    self.numberLabel.text = contact.number;
    
}









@end
